/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package SteamEngineDB;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Jeff Bendixsen <jeff@westcoastcode.com>
 */
@Entity
@Table(name = "CAR")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Car.findAll", query = "SELECT c FROM Car c"),
    @NamedQuery(name = "Car.findById", query = "SELECT c FROM Car c WHERE c.id = :id"),
    @NamedQuery(name = "Car.findByName", query = "SELECT c FROM Car c WHERE c.name = :name"),
    @NamedQuery(name = "Car.findByDescription", query = "SELECT c FROM Car c WHERE c.description = :description"),
    @NamedQuery(name = "Car.findBySeatRows", query = "SELECT c FROM Car c WHERE c.seatRows = :seatRows"),
    @NamedQuery(name = "Car.findBySeatCols", query = "SELECT c FROM Car c WHERE c.seatCols = :seatCols"),
    @NamedQuery(name = "Car.findByDefaultOrder", query = "SELECT c FROM Car c WHERE c.defaultOrder = :defaultOrder")})
public class Car implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @Column(name = "DESCRIPTION")
    private String description;
    @Basic(optional = false)
    @Column(name = "SEAT_ROWS")
    private int seatRows;
    @Basic(optional = false)
    @Column(name = "SEAT_COLS")
    private int seatCols;
    @Basic(optional = false)
    @Column(name = "DEFAULT_ORDER")
    private int defaultOrder;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "carId")
    private Collection<CarSeat> carSeatCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "car")
    private Collection<TemplateCar> templateCarCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "carId")
    private Collection<ScheduleCar> scheduleCarCollection;

    public Car() {
    }

    public Car(Integer id) {
        this.id = id;
    }

    public Car(Integer id, String name, String description, int seatRows, int seatCols, int defaultOrder) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.seatRows = seatRows;
        this.seatCols = seatCols;
        this.defaultOrder = defaultOrder;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getSeatRows() {
        return seatRows;
    }

    public void setSeatRows(int seatRows) {
        this.seatRows = seatRows;
    }

    public int getSeatCols() {
        return seatCols;
    }

    public void setSeatCols(int seatCols) {
        this.seatCols = seatCols;
    }

    public int getDefaultOrder() {
        return defaultOrder;
    }

    public void setDefaultOrder(int defaultOrder) {
        this.defaultOrder = defaultOrder;
    }

    @XmlTransient
    public Collection<CarSeat> getCarSeatCollection() {
        return carSeatCollection;
    }

    public void setCarSeatCollection(Collection<CarSeat> carSeatCollection) {
        this.carSeatCollection = carSeatCollection;
    }

    @XmlTransient
    public Collection<TemplateCar> getTemplateCarCollection() {
        return templateCarCollection;
    }

    public void setTemplateCarCollection(Collection<TemplateCar> templateCarCollection) {
        this.templateCarCollection = templateCarCollection;
    }

    @XmlTransient
    public Collection<ScheduleCar> getScheduleCarCollection() {
        return scheduleCarCollection;
    }

    public void setScheduleCarCollection(Collection<ScheduleCar> scheduleCarCollection) {
        this.scheduleCarCollection = scheduleCarCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Car)) {
            return false;
        }
        Car other = (Car) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "SteamEngineDB.Car[ id=" + id + " ]";
    }
    
}
